package br.net.woodstock.tickettoride.client.web;

public enum TargetType {

	REQUEST_ATTRIBUTE("attribute", new RequestAttributeTargetHandler()), REQUEST_PARAMETER("parameter", new RequestParameterTargetHandler()), SESSION_ATTRIBUTE("session", new SessionAttributeTargetHandler());

	private String					name;

	private TargetHandler	handler;

	private TargetType(final String name, final TargetHandler handler) {
		this.name = name;
		this.handler = handler;
	}

	public String getName() {
		return this.name;
	}

	public TargetHandler getHandler() {
		return this.handler;
	}

	public static TargetType fromName(final String name) {
		for (TargetType type : TargetType.values()) {
			if (type.getName().equals(name)) {
				return type;
			}
		}
		return TargetType.REQUEST_PARAMETER;
	}

}
